<?php
$model = BAModelCooker::getDynamicModel();
$model->addField('isChecked');
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$form = $this->beginWidget('CActiveForm', array(
    "id" => "manage-addRole-form",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('class' => '', 'role' => 'form'),
        ));
?>


<legend>
    <h4><?php
        echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
            'cooker' => 'BAEvent@showEventList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink('管理角色', array(
            'cooker' => 'BAEvent@showEventHome'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink('机构角色', array(
            'cooker' => 'BARoleCooker@showSpaceRoleList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink('角色功能列表', array(
            'cooker' => 'BARoleCooker@showRoleEventList'
        ));
        ?>\
        设置角色功能
    </h4>
</legend>
<div class="">
    <div class="roleList">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th></th>
                    <th>功能别名</th>
                    <th>功能名称</th>
                    <th>功能类型</th>
                    <th>所属应用</th>
                </tr>
            </thead>
            <tbody>
                <?php
                $eventCooker = new BAEventCooker();
                foreach ($eventListData as $id => $eventData) {
                    $eventId = $id;
                    $event = $eventCooker->getEvent($eventId);
                    $eventAlias = $event->getItem('alias')->getValue();
                    $eventName = $event->getItem('name')->getValue();
                    $eventType = $eventCooker->getEventTypeByEvent($event);
                    $typeAlias = $eventCooker->getEventTypeAlias($eventType);
                    $appClass = $eventData['appClass'];


                    if (isset($lastAppClass) && $lastAppClass != $appClass) {
                        echo '<tr><td>---</td></tr>';
                    }
                    $lastAppClass = $appClass;
                    ?>
                    <tr>
                        <td><?php echo CHtml::activeCheckBox($model, "[$id]isChecked"); ?></td>
                        <td><?php echo $eventAlias; ?></td>
                        <td><?php echo $eventName; ?></td>
                        <td><?php echo $typeAlias; ?></td>
                        <td><?php echo yii::t('site', $appClass); ?></td>
                    </tr>

                <?php } ?>
            </tbody>
        </table>
    </div>
    <div>
        <?php
        echo $control->getAjaxLink('添加功能', array(
            'cooker' => 'BARoleCooker@addRoleEvent',
            'htmlOptions' => array(
                'class' => 'btn'
        )));
        ?>
    </div>
</div>
<?php $this->endWidget(); ?>